<?php
    $user=$_POST['user'];
    $pw=$_POST['pw'];
    require('sql.php');
    $result = mysqli_query($conn,"SELECT * FROM yonghu WHERE id='$user'");
//  $rows=mysql_fetch_array($result);//把查询转化为结果集
    $num=mysqli_num_rows($result);
    if($num)//判断结果集非空
    {
    	echo 1;//表示用户名已存在
    }
    else
    {
       if($user!=''){	
      $sql = "INSERT INTO yonghu (id,mima)
       VALUES ('$user', '$pw')";
       mysqli_query($conn, $sql);
       }
       echo 0;//用户已存入
    }
    mysqli_close($conn);
?>